package com.retoc.oawx.service.impl;

import com.retoc.oawx.domain.MessageEntity;
import com.retoc.oawx.domain.MessageRefEntity;
import com.retoc.oawx.mapper.MessageMapper;
import com.retoc.oawx.mapper.MessageRefMapper;
import com.retoc.oawx.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
@Service
public class MessageServiceImpl implements MessageService {
    @Autowired
    private MessageMapper messageMapper;
    @Autowired
    private MessageRefMapper messageRefMapper;

    @Override
    public String insertMessage(MessageEntity entity) {
        return messageMapper.insert(entity);
    }

    @Override
    public String insertRef(MessageRefEntity entity) {
        return messageRefMapper.insert(entity);
    }

    @Override
    public long searchUnreadCount(int userId) {
        return messageRefMapper.searchUnreadCount(userId);
    }

    @Override
    public long searchLastCount(int userId) {
        return messageRefMapper.searchLastCount(userId);
    }

    @Override
    public List<HashMap> searchMessageByPage(int userId, long start, int length) {
        return messageMapper.searchMessageByPage(userId, start, length);
    }

    @Override
    public HashMap searchMessageById(String id) {
        return messageMapper.searchMessageById(id);
    }

    @Override
    public long updateUnreadMessage(String id) {
        return messageRefMapper.updateUnreadMessage(id);
    }

    @Override
    public long deleteMessageRefById(String id) {
        return messageRefMapper.deleteMessageRefById(id);
    }

    @Override
    public long deleteUserMessageRef(int userId) {
        return messageRefMapper.deleteUserMessageRef(userId);
    }
}
